<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%String path=request.getContextPath();String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<%@include file="../include/contentheader.jsp"%>
	<link rel="stylesheet" type="text/css" href="css/dtree.css"/>
	<link rel="stylesheet" type="text/css" href="css/main.css"/>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	<script type="text/javascript" src="js/dtree.js"></script>
  </head>
<script type="text/javascript">
  $(document).ready(function(){
  		$('input#queryUser').click(function(){
  			location.href="findUserByName.action?un="+$('input#queryBy').val()+"&qm="+$('select#queryMethod').val();
  		});
  		$('input#addUser').click(function(){
  			location.href="addUser.action";
  		});
  		$('input#refresh').click(function(){
			location.href="findAllUser.action";
  	  	});
  	  	$('input#updateUser').click(function(){
  			  	var userList = new Array();
		 	 	var num = 0;
				$('input[id="userCode"]').each(function(i){
					if($(this).attr('checked')){
						userList[num++] = $(this).val();
					}
				});
				if(userList.length==0){
					alert('请选择');
					return;
				}else if(userList.length>1){
					alert('只能选择一个');
					return;
				}
				location.href="getUserByCode.action?un="+encodeURIComponent(userList[0]);
  	  	 	});
  	  	$('input#deleteUser').click(function(){
  	  		var question = confirm("你确认要删除所选信息?");
	  	  	if(question!='0'){
  	  	 	 	var userList = new Array();
  	  		  	var num = 0;
				$('input[id="userCode"]').each(function(i){
					if($(this).attr('checked')){
						userList[num++] = $(this).val();
					}
				});
				var url = "deleteUser.action";
				if(userList.length>=1){
					for(var z = 0; z < userList.length;z++){
						if(z==0){
							url += "?deleteUsers="+userList[z];
						}else{
							url += "&deleteUsers="+userList[z];
						}
					}
				}
				location.href=url;
	  	  	}
  		});
  	});
  	
  </script>
  <body>
<div class="mainContainer">
	<div class="headerTitle"><s:property value="navStr" /></div>
	<div class="dataDivLeftNoTree">
		
<table class="gridTable" border="0" cellspacing="0" cellpadding="0">
	<tr class="operatorAction">
		<td>
			<!-- 功能性操作 -->
			<input id="refresh" type="button" style="margin-left:2px;" value="刷新" />
			<input id="addUser" type="button" style="margin-left:2px;" value="新增" />
			<input id="updateUser" type="button" style="margin-left:2px;"  value="修改" />
			<input id="deleteUser" type="button" style="margin-left:2px;" value="删除" />
			<input type="button" style="margin-left:2px;" onclick="doExport();" value="导出" />
				<select id="queryMethod" style="width:120px;">
					<option value="0" selected="selected">查询方式</option>
					<option value="1">按用户名查询</option>
					<option value="2">按用户编号查询</option>
					<option value="3">按使用人查询</option>
					<option value="4">按权限模板查询</option>
					<option value="5">按部门查询</option>
				</select>
				<input id="queryBy" type="text" class="qryTxt"/>
				<input id="queryUser" type="submit" style="margin-left:1px;" value="查询" />
		</td>
	</tr>
    <tr>
		<td class="gridData">
		
			<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
	          <tr class="dataHeader">
	          	<!-- 数据表头 -->
	            <td width="2%"><input id="checkAll" type="checkbox" /></td>
	            <td width="10%">账号</td>
	            <td width="10%">用户名</td>
	            <td width="10%">使用者</td>
	            <td width="10%">权限模板</td>
	            <td width="10%">部门</td>
	            <td width="5%">状态</td>
	            <td width="10%">最近登陆时间</td>
	            <td width="10%">最近改动时间</td>
	          </tr>
	          
	           <!-- 数据 -->
	            <s:iterator var="s" value="sysUsers">
	          
 				<tr class="dataRow">
 					<td><input id="userCode" name="userCode" type="checkbox" value="<s:property value="#s.userCode"/>" /></td>
 					<td><s:property value="#s.userCode"/></td>
		            <td><s:property value="#s.userName"/></td>
		            
		           <td><s:iterator var="f" value="staffs"><s:if test="#s.staid==#f.staid"><s:property value="#f.staname"/></s:if> </s:iterator></td>
		            
		            <td><s:iterator var="t" value="sysTemplates"><s:if test="#s.templateCode==#t.templateCode"><s:property value="#t.templateName"/></s:if> </s:iterator></td>
		            <td><s:iterator var="d" value="departments"><s:if test="#s.deptCode==#d.depid"><s:property value="#d.depname"/></s:if></s:iterator></td>
		            <td><s:if test="#s.status==\"A\"">在用</s:if><s:else>停用</s:else></td>
		            <td><s:date name="#s.lastLogin" format="yyyy/MM/dd HH:mm"/></td>
		            <td><s:date name="#s.lastChgPwd" format="yyyy/MM/dd HH:mm"/></td>
		            </tr>
   				</s:iterator>
			</table>
			
		</td>
	</tr>
	<tr class="dataPager">
		<td>
			<s:property value="pageLink" escapeHtml="false" />
		</td>
	</tr>
</table>

	</div>
</div>
	<form action="tmplt-del" method="post" id="HIDDENFORM" name="HIDDENFORM">
		<input type="hidden" id="FN" name="FN" value="<s:property value='FN' />" />
		<input type="hidden" id="t" name="t" value="" />
	</form>
  </body>
</html>
